home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-16 | 2.5 KB | 69 lines | [TEXT/MPS ] |
- #----------------------------------------------------------------------------------------------------------------------------------------------------
- # RenameProjectorFile
- # MPW Shell Script
- # Written by Gina Cherry • August 16, 1991
- # Copyright: © 1991 by Apple Computer, Inc., all rights reserved.
- #
- # WARNING:
- # This script was written to demonstrate some of the features of the MPW command language, and
- # is not recommended for actual use. All previous versions of the Projector file will be lost
- # when the file is renamed. To rename Projector files, use the script ChangeFileName found in
- # MPW Goodies.
- #
- # Usage:
- # RenameProjectorFile oldName newName
- #
- # Function:
- # RenameProjectorFile renames the specified Projector file.
- #
- # Note:
- # RenameProjectorFile will always display an Alert warning the user that the old file is
- # not in the current checkout directory.
- #----------------------------------------------------------------------------------------------------------------------------------------------------
-
-
- # If the number of parameters is not equal to 2, write error message and exit script.
- If {#} != 2
- Echo "### Usage: {0} oldName newName"
- Exit 1
- End >> Dev:StdErr
-
- # Don't exit on error.
- Set Exit 0
-
- # Set variables to specified files.
- Set oldName "{1}"
- Set newName "{2}"
-
- # Check out a write-priveleged copy of the file to be renamed. If the CheckOut command is
- # not successful, exit the script.
- CheckOut -m "{oldName}" || Exit 2
-
- # Set info variable to the information returned by the ProjectInfo command.
- Set info "`ProjectInfo -comments "{oldName}"`"
-
- # Parse this information to extract the revision number, the task, and the comment. Create
- # tag variables to remember this information.
- If "{info}" =~ /[∂']*≈,([¬ ∂']+)®1∂+[∂']*≈ Task: (≈)®2[ ]«5»Comment: (≈)®3/
- Set revision "{®1}"
- Set task "{®2}"
- Set comment "Renamed from "{oldName}". {®3}"
- End
-
- # Orphan the file from its project.
- OrphanFiles "{oldName}"
-
- # Rename the file to the specified new name.
- Rename "{oldName}" "{newName}"
-
- # Check in the newly named file as a new file. The new file will have the same revision number as
- # the most recent revision of the old name, and will have the same comment and task fields.
- CheckIn -new "{newName},{revision}" -cs "{comment}" -t "{task}"
-
- # Cancel the check out of the old name. Note: This command will produce an Alert since the old name
- # is no longer in the Projector database.
- CheckOut -cancel "{oldName}" -y
-
- # Delete all revisions of the old name.
- DeleteRevisions -file "{oldName}" -y
-